#pragma once

#include <iostream>
#include <string>
#include <pthread.h>

class mutex
{
public:
    mutex(pthread_mutex_t* mtx)
        : _mutex(mtx)
    {}

    ~mutex()
    {}

    void lock()
    {
        pthread_mutex_lock(_mutex);
    }
    void unlock()
    {
        pthread_mutex_unlock(_mutex);
    }

private:
    pthread_mutex_t* _mutex;

};

class lock_guard
{
public:
    lock_guard(pthread_mutex_t* mtx)
        : _mutex(mtx)
    {
        _mutex.lock();
    }

    ~lock_guard()
    {
        _mutex.unlock();
    }

private:
    mutex _mutex;
};
